using System;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;

public class Excel2ConfigEditor : MonoBehaviour
{
    [MenuItem("Tools/Hyu/Excel2Config")]
    public static void Excel2Config()
    {
        //计时
        DateTime beginTime= DateTime.Now;
        
        Process proc = new Process();
        proc.StartInfo.WorkingDirectory = @".\Excels\TransTool\";
        proc.StartInfo.FileName = "unityRun.bat";

        proc.Start();
        proc.WaitForExit();
        
        AssetImporter importer=AssetImporter.GetAtPath("Assets/Res/Configs");
        if(importer != null)
        {
            importer.assetBundleName="configs";
        }
        
        var time= DateTime.Now-beginTime;
        Debug.Log("完成将Excel导出为Config，用时："+time.TotalMilliseconds+"ms");
        AssetDatabase.Refresh();
    }
}
